#include<iostream>
typedef long long ll;
const int N = 1e6 + 10;
ll a[N], b[N], c[N];
using namespace std;
int main()
{
	int n, x , m;cin >> n >> m >> x;
	for (int i = 2; i <= m; i++)
	{
		int y;cin >> y;
		if (x < y)
		{
			a[x]++;
			a[y]--;
		}
		else
		{
			a[x]--;
			a[y]++;
		}
		x = y;
	}
	for (int i = 1; i <= n; i++)
	{
		a[i] += a[i - 1];
	}
	ll sum = 0;
	for (int i = 1; i <= n - 1; i++)
	{
		ll j, q, k;cin >> j >> q >> k;
		sum += min(j * a[i] , k + q * a[i]);
	}
	cout << sum << endl;
	return 0;
}
//#include<iostream>
//const int N = 1e6 + 10;
//long long  a[N],b[N],c[N];
//using namespace std;
//typedef long long ll;
//int main()
//{
//	ll n, m;cin >> n >> m >> b[1];
//	for (int i = 2; i <=m; i++)
//	{
//		cin >> b[i];
//		ll ret = min(b[i - 1], b[i]);
//		ll ans = max(b[i - 1], b[i]);
//		a[ret]++;
//		a[ans]--;
//	}
//	ll sum = 0;
//	for (int i = 1; i <= n; i++)
//	{
//		a[i] += a[i - 1];
//	}
//	for (int i = 1; i <= n - 1 ; i++)
//	{
//		ll k, b, c;cin >> k >> b >> c;
//		sum += min(k * a[i], c + a[i] * b);
//	}
//	cout << sum << endl;
//		return 0;
//}